/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 combat_flinch.h

	$Header: /heroes4/three_head_attack.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( COMBAT_FLINCH_H_INCLUDED )
#define COMBAT_FLINCH_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "combat_action_message.h"
#include "combat_object_list.h"
#include "handler.h"

class t_attackable_object;
class t_battlefield;
class t_combat_creature;

// ------------------------------------------------------------
// play an appropriate flinch animation for a list of creatures
// ------------------------------------------------------------
class t_combat_flinch : public t_handler_base_1<t_combat_creature&>
{
public:
	t_combat_flinch( t_combat_creature& attacker, t_combat_action_message const & message );
	t_combat_flinch( t_combat_creature& attacker, t_attackable_object& defender, t_combat_action_message const & message, bool robe_only = false );
	void add( t_attackable_object& defender, bool robe_only = false );

	virtual void operator()( t_combat_creature& creature );
protected:
	struct t_flincher
	{
		t_combat_object_ptr flincher;
		bool				robe_only;
	};

	typedef std::list< t_flincher > t_flincher_list;

	t_combat_creature const&  m_attacker;
	t_combat_action_message   m_message;
	t_flincher_list		      m_targets;
};

inline t_combat_flinch::t_combat_flinch( t_combat_creature& attacker, t_combat_action_message const & message) 
					  : m_attacker( attacker ), m_message( message )
{
}

inline t_combat_flinch::t_combat_flinch( t_combat_creature&				 attacker, 
										 t_attackable_object&			 defender,
										 t_combat_action_message const & message,
										 bool robe_only)
					  : m_attacker( attacker ), m_message( message )
{
	add( defender, robe_only );
}

#endif // COMBAT_FLINCH_H_INCLUDED
